package interfaces.hud.pilot.equipment;

import interfaces.hud.BasicHUD;
import logic.weapons.projectileWeapons.ProjectileChangedEvent;
import logic.weapons.projectileWeapons.ProjectileListener;
import logic.weapons.projectileWeapons.ProjectileWeapon;

public class ProjectileWeaponButton extends WeaponButton {
	
	public ProjectileWeaponButton(ProjectileWeapon weapon, int width, int height, BasicHUD hud) {
		super(weapon, width, height, hud);
		
		hud.addListener(weapon, new ProjectileListener() {
			@Override
			public void projectilesChanged(ProjectileChangedEvent event) {
				updateProjectiles(event.getNewAmount());
			}
		});
		
		updateProjectiles(weapon.getProjectilesLeft());
	}
	
	public void updateProjectiles(int projectiles) {
		weaponButton.setText(weapon.getName() + " (" + projectiles + ")");
	}
}